<?php

namespace app\modules\v1\filters;


use common\libraries\WriteLogSrv;
use Yii;

/**
 *
 */
class Secure extends \common\filters\BaseFilter
{

    public function beforeAction($action)
    {
        if ($this->checkExcept()) {
            return true;
        }
        $key = Yii::$app->getRequest()->url . $this->owner->sessionId;
        if (Yii::$app->getRequest()->isPost && Access::getCacheValue($key)) {
            WriteLogSrv::writeLog('请勿重复提交：'.$key);
            $this->owner->error('请勿重复提交。');
        }
        if(Yii::$app->getRequest()->isPost) {
            WriteLogSrv::writeLog('写入：' . $key);
            Access::setCacheValue($key);
        }
        return true;
    }

}
